import { http } from '@/package_tms/utils/request.js'
import { HomeList } from './types'
enum Urls {
	storeList = 'mini/driver/store_list',
	orderList = 'mini/driver/order_list',
	Detail = 'mini/driver/order_info',
	Sign = 'mini/driver/pay',
	accountList = 'mini/account/list',
	shopList = 'mini/driver/shop_list',
	shopEdit = 'mini/driver/shop_edit'
}

// 列表
interface ListResponse<T> extends IBaseResponse {
	data : {
		current_page : number
		data : Array<T>
		last_page : number
		per_page : number
		total : number,
		undone : number,
		done : number
	}
}
// 配送任务列表
type GetListApi = (data : Partial<ListParams>) => Promise<ListResponse<HomeList>>
export const getListApi : GetListApi = (params) => http.get(Urls.storeList, params)

// 配送订单列表
export const getOrderListApi = (params) => http.get(Urls.orderList, params)

// 详情
type DetailParams = { order_id : string }
type GetDetailApi = (data : DetailParams) => Promise<IListResponse<HomeList>>
export const getDetailApi : GetDetailApi = (params) => http.get(Urls.Detail, params)

// 签收
type SignParams = { id : string, img : string }
type SignApi = (data : SignParams) => Promise<IListResponse<HomeList>>
export const signApi : SignApi = (data) => http.post(Urls.Sign, data)

// 司机对账列表
export const accountList = (params) => http.get(Urls.accountList, params)

// 门店列表
export const shopList = (params) => http.get(Urls.shopList, params)

// 门店修改
export const shopEdit = (data) => http.post(Urls.shopEdit, data)